package factory;

import dao.NewsDao;
import dao.impl.NewsDaoImpl;
import dao.impl.NewsDaoOracleImpl;
import dao.impl.NewsDaoRedisImpl;

/**
 * @author 黄军艳
 * @version 1.0
 * @date 2024/11/25  16:08
 */
public class SimpleDaoFactory {
    /**
     * 创建NewsDao实例的工厂方法
     * @return
     */
    public static NewsDao getInstance(String key){
        //return new NewsDaoImpl();
        switch (key){
            case "mysql":
                return new NewsDaoImpl();
            case "oracle":
                return new NewsDaoOracleImpl();
            case "redis":
                return new NewsDaoRedisImpl();
            default:
                throw new RuntimeException("无效的数据库类型："+key);
        }
    }
}
